package com.tjhk.design.protype;

import java.util.Hashtable;

public class ShapeCache {
    private static Hashtable<String,Shape> shapeHashtable = new Hashtable<>();
    public static void loadCache(){
        Circle circle = new Circle();
        circle.setId("1");
        shapeHashtable.put(circle.getId(),new Circle());
        Rectangle rectangle = new Rectangle();
        rectangle.setId("2");
        shapeHashtable.put(rectangle.getId(),rectangle);
        Square square = new Square();
        square.setId("3");
        shapeHashtable.put(square.getId(),square);
    }
    public static Shape getShape(String id){
        return (Shape) shapeHashtable.get(id).clone();
    }
}
